/*
package com.sjb.mianshiya.job;

import com.sjb.mianshiya.model.domain.Question;
import com.sjb.mianshiya.model.dto.question.QuestionEsDto;
import com.sjb.mianshiya.service.QuestionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

*/
/**
 * @Author:sjb
 * @CreateTime:2024-11-15
 * @Description: 向ES同步数据
 * @Version：1.0
 *//*

@Component
@Slf4j
public class FullSyncQuestionToEs implements CommandLineRunner {


    @Resource
    private QuestionService questionService;
    
    */
/*@Resource
    private QuestionEsDao questionEsDao;*//*


    @Override
    public void run(String... args) throws Exception {

        List<Question> allQuestionList = questionService.list();
        if (CollectionUtils.isEmpty(allQuestionList)) {
            return;
        }
        List<QuestionEsDto> questionEsDtoS =
                allQuestionList.stream().map(QuestionEsDto::objToDto).collect(Collectors.toList());
        // 分页批量插入到Es
        final int pageSize = 500;
        int total = questionEsDtoS.size();
        log.info("FullSyncQuestionToEs start, total {}", total);

        for (int i = 0; i < total; i+= pageSize) {
            int end = Math.min(i + pageSize, total);
            log.info("sync from {} to {}", i, end);
            List<QuestionEsDto> saveToQuestionEsDtoS = questionEsDtoS.subList(i, end);
            //questionEsDao.saveAll(saveToQuestionEsDtoS);
        }
        log.info("FullSyncQuestionToEs end, total {}", total);
    }
}
*/
